<script type="text/javascript">
    function pic_upload_success(file, data) {
        var json = $.parseJSON(data)

        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#j_custom_pic').val(json.filename)
            $('#j_custom_span_pic').html('已上传图片：<img src="/'+ json.filename +'" width="100">')
        }
    }
    function icon_upload_success(file, data) {
        var json = $.parseJSON(data)

        $(this).bjuiajax('ajaxDone', json)
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $('#icon_custom_pic').val(json.filename)
            $('#icon_custom_span_pic').html('已上传图片：<img src="/'+ json.filename +'" width="100">')
        }
    }
    $(document).ready(function(){
        $("#period").blur(function(){
            if($("#period").val() != '') {
                if(!/^\d+$/.test($("#period").val())){
                    alert("任务间隔周期必须是正整数！");
                }
            }
        });
        $("#degree").blur(function(){
            if($("#degree").val() != '') {
                if(!/^\d+$/.test($("#degree").val())){
                    alert("任务完成(次数)必须是正整数！");
                }
            }
        });
        $("#integration").blur(function(){
            if($("#integration").val() != '') {
                if(!/^\d+$/.test($("#integration").val())){
                    alert("奖励金币数量必须是正整数！");
                }
            }
        });
    });
</script>
<div class="bjui-pageContent">
    <div class="bjui-doc">
        <h3 class="page-header">新增Banner</h3>
        <form method="post" action="{:U($Think.ACTION_NAME)}" data-toggle="validate" id="msg-push-form" class="pageForm" data-reload-navtab="true">
            <input type="hidden" name="uid" value="{$uid}" />
            <input type="hidden" name="id" value="{$data['id']}" />
            <div class="row-fluid">
                <div class="control-group">
                    <label for="title" class="control-label">任务名称：</label>
                    <div class="controls">
                        <input type="text" name="title" id="title" value="{$data['title']}" data-rule="required" data-tip="不超过 50 字节" />
                    </div>
                </div>
                <div class="control-group">
                    <label for="desp" class="control-label">任务描述：</label>
                    <div class="controls">
                        <textarea rows="6"  data-rule="required" data-tip="任务的详细说明"  name="desp" id="desp" cols="50" class="tarea">{$data['desp']}</textarea>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" title="">任务间隔周期单位：</label><span>设置任务间隔周期的计算单位</span>
                    <div class="controls">
                        <input type="radio" name="periodtype" value="0" data-toggle="icheck" data-label="小时" data-tip="表示指定小时后可再次申请，间隔周期填写间隔的小时数" <eq name="data['periodtype']" value="0">checked</eq> >
                        <input type="radio" name="periodtype" value="1" data-toggle="icheck" data-label="天" data-tip="表示指定天后可再次申请，间隔周期填写间隔的天数" <eq name="data['periodtype']" value="1">checked</eq> >
                        <input type="radio" name="periodtype" value="2" data-toggle="icheck" data-label="周" data-tip="表示在每周指定时间(周一到周日)后才可再次申请，间隔周期填写数字 1 (周一) 到 7 (周日)" <eq name="data['periodtype']" value="2">checked</eq> >
                        <input type="radio" name="periodtype" value="3" data-toggle="icheck" data-label="月" data-tip="表示在每月指定日期后才可再次申请，间隔周期填写数字 1 到 29、30、31" <eq name="data['periodtype']" value="3">checked</eq> >
                    </div>
                </div>
                <div class="control-group">
                    <label for="period" class="control-label">任务间隔周期：</label>
                    <div class="controls">
                        <input type="text" name="period" id="period" value="{$data['period']}" data-rule="required;number" data-tip="留空表示一次性任务，否则为周期性任务" />
                    </div>
                </div>
                <div class="control-group">
                    <label for="degree" class="control-label">任务完成(次数)：</label>
                    <div class="controls">
                        <input type="text" name="degree" id="degree" value="{$data['degree']}" data-rule="required;number" data-tip="任务达到一定次数后算完成" />
                    </div>
                </div>
                <div class="control-group">
                    <label for="integration" class="control-label">奖励金币数量：</label>
                    <div class="controls">
                        <input type="text" name="integration" id="integration" value="{$data['integration']}" data-rule="required;number" data-tip="任务达到一定次数后算完成" />
                    </div>
                </div>
                <div class="control-group">
                    <label for="genre" class="control-label">任务类型：</label>
                    <div class="controls">
                        <select name="genre" id="genre" data-toggle="selectpicker">
                            <option value="0" <eq name="data['genre']" value="0">selected</eq> >帖子发送类</option>
                            <option value="1" <eq name="data['genre']" value="1">selected</eq> >完成调查</option>
                            <option value="2" <eq name="data['genre']" value="2">selected</eq> >分享检查</option>
                            <option value="3" <eq name="data['genre']" value="3">selected</eq> >邀请类</option>
                            <option value="4" <eq name="data['genre']" value="4">selected</eq> >签到</option>
                            <option value="5" <eq name="data['genre']" value="5">selected</eq> >关注</option>
                            <option value="6" <eq name="data['genre']" value="6">selected</eq> >订阅</option>
                            <option value="7" <eq name="data['genre']" value="7">selected</eq> >活动点击</option>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label for="groups" class="control-label">任务分组：</label>
                    <div class="controls">
                        <select name="groups" id="groups" data-toggle="selectpicker">
                            <option value="0" <eq name="data['groups']" value="0">selected</eq> >新手任务</option>
                            <option value="1" <eq name="data['groups']" value="1">selected</eq> >日常任务</option>
                            <option value="2" <eq name="data['groups']" value="2">selected</eq> >成长任务</option>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">任务图标：</label>
                    <div class="controls">
                        <div style="display: inline-block; vertical-align: middle;">
                            <div id="icon_custom_pic_up" data-toggle="upload" data-uploader="{:U('upload')}"
                                 data-file-size-limit="1024000000"
                                 data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
                                 data-multi="true"
                                 data-on-upload-success="icon_upload_success"
                                 data-icon="cloud-upload"></div>
                            <input type="text" name="icon" value="{$data['icon']}" id="icon_custom_pic" data-rule="required" data-msg-required="请上传任务图标" style="width:300px">
                            <span id="icon_custom_span_pic"></span>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">任务Banner图片：</label>
                    <div class="controls">
                        <div style="display: inline-block; vertical-align: middle;">
                            <div id="j_custom_pic_up" data-toggle="upload" data-uploader="{:U('upload')}"
                                 data-file-size-limit="1024000000"
                                 data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
                                 data-multi="true"
                                 data-on-upload-success="pic_upload_success"
                                 data-icon="cloud-upload"></div>
                            <input type="text" name="adsimg" value="{$data['adsimg']}" id="j_custom_pic" data-rule="required" data-msg-required="任务Banner图片" style="width:300px">
                            <span id="j_custom_span_pic"></span>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
    </ul>
</div>